package com.chu.dao.impl;

import com.chu.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class UserDaoImpl implements UserDao {
    @Autowired
    private JdbcTemplate jt;
    @Override
    public void addMoney(Integer addUserId, Integer money) {
        String sql = "update user set money = money + ? where id = ?";
        jt.update(sql,money,addUserId);
    }

    @Override
    public void subMoney(Integer subUserId, Integer money) {
        String sql = "update user set money = money - ? where id = ?";
        jt.update(sql,money,subUserId);
    }
}
